package com.ktjy.entity;

import java.util.List;

/**
 * 分页的工具类
 * @version v1.0
 * @Author JieGe
 * @Create 2024-11-21 - 10:24
 */
public class Page<T> {
    private Integer currPageNo = 1; // 当前页码
    private Integer pageSize = 5; // 每页显示的数据行数
    private Integer totalCount = 0; // 总的记录数
    private Integer totalPageCount = 0; // 总的页数
    private List<T> list;  // 保存每页查询到列表数据， T为泛型，即任意类型

    @Override
    public String toString() {
        return "Page{" +
                "currPageNo=" + currPageNo +
                ", pageSize=" + pageSize +
                ", totalCount=" + totalCount +
                ", totalPageCount=" + totalPageCount +
                ", list=" + list +
                '}';
    }

    public Integer getCurrPageNo() {
        return currPageNo;
    }

    public void setCurrPageNo(Integer currPageNo) {
        this.currPageNo = currPageNo;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(Integer totalCount) {
        if (totalCount > 0) {
            this.totalCount = totalCount;

            // 根据总记录数以及每页显示的数据行数，计算总的页数   如：总记录为：10 每页显示4条。
            this.totalPageCount = this.totalCount % this.pageSize == 0 ? this.totalCount / this.pageSize : this.totalCount / this.pageSize + 1;
        }
    }

    public Integer getTotalPageCount() {
        return totalPageCount;
    }

    public void setTotalPageCount(Integer totalPageCount) {
        this.totalPageCount = totalPageCount;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }
}
